package com.example.healthcondition.controller;

import com.example.healthcondition.entity.DietPlans;
import com.example.healthcondition.services.DietPlansService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/api/login/home/dietPlans")
public class DietPlansController {

    private final DietPlansService dietPlansService;

    @Autowired
    public DietPlansController(DietPlansService dietPlansService) {
        this.dietPlansService = dietPlansService;
    }

    @PostMapping("/generate/{userId}")
    public DietPlans generateDietPlan(@PathVariable Integer userId) {
        return dietPlansService.generateDietPlan(userId);
    }

    @GetMapping("/{planId}")
    public Map<String,Object> getDietPlanById(@PathVariable Integer planId) {
        return dietPlansService.getDietPlanById(planId);
    }

    @PostMapping
    public int addDietPlan(@RequestBody DietPlans dietPlans) {
        return dietPlansService.insertDietPlan(dietPlans);
    }
}
